<?php
/**
 * Template Name: P2Blog
 *
 * If you want to set up an alternate blog page, just use this template for your page.
 * This template shows your latest posts.
 * @link http://themehybrid.com/themes/hybrid/page-templates/blog
 *
 * @package Hybrid
 * @subpackage Template
 */

global $is_page_template_page;
global $p2_custom_post_type;
$siteurl = get_bloginfo('url');
//$custom_post_type_rss_url = $siteurl . "/feed/?post_type=$p2_custom_post_type";
$custom_post_type_rss_url = 'http://feeds2.feedburner.com/humbugin';
get_header(); ?>
<div class="sleeve_main">
<?php 
	if ( p2_user_can_post() && !is_archive() ) {
		locate_template( array( 'p2/post-form.php' ), true );
	}
?>
	<div id="content" class="hfeed content p2blog">

		<?php hybrid_before_content(); // Before content hook ?>
		<h2 class="p2announcement">
			<?php if ( $is_page_template_page ) : ?>
		
				<?php _e( 'Recent Updates' , 'p2' ) ?> <?php if ( p2_get_page_number() > 1 ) printf( __( ' | Page %s', 'p2' ), p2_get_page_number() ); ?>
				<a class="rss" href="<?php echo $custom_post_type_rss_url ?>">RSS</a>

			<?php elseif ( is_author() ) : ?>
				
				<?php printf( _x( 'Updates from %s', 'Author name', 'p2' ), p2_get_archive_author() ) ?>
				<a class="rss" href="<?php p2_author_feed_link() ?>">RSS</a>
				
			<?php elseif ( is_taxonomy( 'mentions' ) ) : ?>

				<?php printf( _x( 'Posts Mentioning %s', 'Author name', 'p2' ), p2_get_mention_name() ) ?>
				<a class="rss" href="<?php p2_author_feed_link() ?>">RSS</a>
		
			<?php else : ?>
		
				<?php printf( _x( 'Updates from %s', 'Month name', 'p2' ), get_the_time( 'F, Y' ) ); ?>
		
			<?php endif; ?>
	
			<span class="controls">
				<a href="#" id="togglecomments"> <?php _e( 'Toggle Comment Threads', 'p2' ); ?></a> | <a href="#directions" id="directions-keyboard"><?php _e( 'Keyboard Shortcuts', 'p2' ); ?></a>
			</span>
		</h2>
		
		<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
		<?php $temp = $wp_query; $wp_query = null; ?>
		<?php $wp_query = new WP_Query( array( 'post_type' => 'aside', 'posts_per_page' => 10, 'paged' => $paged) ); ?>

		<?php if ( $wp_query->have_posts() ) : while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

			<div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">

				<?php hybrid_before_entry(); // Before entry hook ?>

				<div class="entry-content">
					<ul id="postlist">
						<?php p2_load_entry() // loads entry.php ?>
					</ul>
				</div><!-- .entry-content -->

				<?php hybrid_after_entry(); // After entry hook ?>

			</div><!-- .hentry -->

			<?php endwhile; ?>

			<?php hybrid_after_singular(); // After singular hook ?>

		<?php else: ?>

			<p class="no-data">
				<?php _e( 'Apologies, but no results were found.', 'hybrid' ); ?>
			</p><!-- .no-data -->

		<?php endif; ?>

		<?php hybrid_after_content(); // After content hook ?>
		<?php $wp_query = null; $wp_query = $temp; ?>
	</div><!-- .content .hfeed -->
</div> <!-- sleeve -->

<?php get_footer(); ?>
